package com.player.jsp;

import java.io.Serializable;

import com.google.appengine.api.users.UserServiceFactory;

public class SessionBean implements Serializable {

	private static final long serialVersionUID = 7801312781008030181L;

	private String pageUri;
	private String email;

	private boolean isRegistered;
	private boolean isUserSwitched;

	private boolean debug = false;

	public SessionBean() {
		super();
	}

	public String getPageUri() {
		return pageUri;
	}

	public String getEmail() {
		return email;
	}

	public boolean isLoggedIn() {
		return email != null && !email.equals("");
	}

	public boolean isRegistered() {
		return isRegistered;
	}

	@Deprecated
	public boolean isUserSwitched() {
		return isUserSwitched;
	}

	public void setPageUri(String pageUri) {
		this.pageUri = pageUri;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setRegistered(boolean isRegistered) {
		this.isRegistered = isRegistered;
	}

	@Deprecated
	public void setUserSwitched(boolean isUserSwitched) {
		this.isUserSwitched = isUserSwitched;
	}

	public void setDebug(boolean debug) {
		this.debug = debug;
	}

	public boolean isDebug() {
		return debug;
	}

	public String createLoginURL(String destinationURL) {
		return UserServiceFactory.getUserService().createLoginURL(destinationURL);
	}

	public String createLogoutURL(String destinationURL) {
		return UserServiceFactory.getUserService().createLogoutURL(destinationURL);
	}

	@Override
	public String toString() {
		return "SessionBean [email=" + email + ", isLoggedIn=" + isLoggedIn() + ", isRegistered=" + isRegistered
				+ ", isUserSwitched=" + isUserSwitched + ", pageUri=" + pageUri + "]";
	}
}
